<template>
  <div class="app-container">
    <!-- 搜索 -->
    <el-card class="search-card">
      <el-form :model="queryParams" size="small" class="formBox" label-width="88px">
        <el-row :gutter="0">
          <el-col :span="5">
            <el-form-item label="姓名" prop="name">
              <el-input
                v-model="queryParams.name"
                placeholder="请输入姓名"
                clearable
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="身份证号" prop="idCardNumber">
              <el-input
                v-model="queryParams.idCardNumber"
                placeholder="请输入身份证号"
                clearable
                style="width: 100%"
              />
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="校区名称" prop="campusId">
              <el-select
                v-model="queryParams.campusId"
                placeholder="请选择校区名称"
                @change="listGradeFun"
                style="width: 100%"
              >
                <el-option
                  v-for="(item, index) in campusList"
                  :key="index"
                  :value="item.id"
                  :label="item.campusName"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="年级名称" prop="gradeId">
              <el-select
                v-model="queryParams.gradeId"
                placeholder="请选择年级名称"
                style="width: 100%"
                @change="gradeFun"
              >
                <el-option
                  v-for="(item, index) in gradeList"
                  :key="index"
                  :value="item.id"
                  :label="item.gradeName"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="5">
            <el-form-item label="班级" prop="classId">
              <el-select
                v-model="queryParams.classId"
                placeholder="请选择班级"
                style="width: 100%"
              >
                <el-option
                  v-for="(item, index) in classList"
                  :key="index"
                  :value="item.id"
                  :label="item.className"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <!-- <el-col :span="5">
            <el-form-item label="团餐计划" prop="classId">
              <el-select
                v-model="queryParams.classId"
                placeholder="请选择团餐计划"
                style="width: 100%"
              >
                <el-option
                  v-for="(item, index) in classList"
                  :key="index"
                  :value="item.id"
                  :label="item.className"
                >
                </el-option>
              </el-select>
            </el-form-item>
          </el-col> -->
          <el-col :span="24">
            <el-form-item>
              <div class="dis aic">
                <div class="flex_1"></div>
                <el-button
                  type="primary"
                  icon="el-icon-search"
                  size="mini"
                  @click="handleQuery"
                >
                  搜索
                </el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">
                  重置
                </el-button>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </el-card>
    <!-- 按钮 -->
    <el-card class="search-card">
      <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button
            type="warning"
            plain
            icon="el-icon-download"
            size="mini"
            @click="handleExport"
            v-hasPermi="['campus:unpaid:export']"
          >
            导出
          </el-button>
        </el-col>
        <right-toolbar
          :showSearch.sync="showSearch"
          @queryTable="getList"
        ></right-toolbar>
      </el-row>
    </el-card>
    <el-card class="table-card">
      <el-table :data="dataList">
        <el-table-column label="学生姓名" align="center" prop="name" />
        <el-table-column label="性别" align="center" prop="sex" />
        <el-table-column label="身份证号" align="center" prop="idNumber" />
        <el-table-column label="联系电话" align="center" prop="phone" />
        <el-table-column label="校区" align="center" prop="campusName" />
        <el-table-column label="年级" align="center" prop="gradeName" />
        <el-table-column label="班级" align="center" prop="className" />
        <el-table-column label="团餐计划" align="center" prop="teamPlanName" />
        <el-table-column label="缴费状态" align="center" prop="payStatus" />
        <el-table-column label="账单金额" align="center" prop="phoneNumber" />
      </el-table>
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>
  </div>
</template>
<script>
import { listGrade } from "@/api/campus/grade";
import { getCampusLists } from "@/api/campus/all";
import { listClassManage } from "@/api/campus/classManage";
import { noPayPersonList, insertNoPayPerson } from "@/api/teamMeal/unpaid";

export default {
  name: "unpaid",
  data() {
    return {
      // 选中数组
      ids: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      dataList: [],
      campusList: [],
      gradeList: [],
      classList: [],
    };
  },
  created() {
    this.getCampusListsFun();
    this.getList();
  },
  activated() {},
  methods: {
    /** 查询班级管理列表 */
    getList() {
      this.loading = true;
      noPayPersonList(this.queryParams).then((response) => {
       if(response.code==200){
        this.dataList = response.data.rows;
        this.total = response.data.total;
        this.loading = false;
       }
      });
    },
    /**
     * 获取校园列表
     *
     * 调用后端接口获取校园列表，并将结果赋值给当前组件的campusList属性。
     */
    getCampusListsFun() {
      getCampusLists({ schoolId: null }).then((res) => {
        if (res.code == 200) {
          this.campusList = res.data;
        }
      });
    },

    /**
     * 获取成绩列表
     *
     * @param options 包含校区ID的对象
     */
    listGradeFun(options) {
      listGrade({ pageNum: 1, pageSize: 200, campusId: options }).then((res) => {
        if (res.code == 200) {
          this.gradeList = res.rows;
        }
      });
    },
    /**
     * 获取班级列表
     *
     * @param options - 年级ID
     */
    gradeFun(options) {
      this.$set(this.queryParams, "classId", "");
      listClassManage({ pageNum: 1, pageSize: 200, gradeId: options }).then(
        (response) => {
          this.classList = response.rows;
        }
      );
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    handleExport() {},
  },
};
</script>
<style>
.formBox >>> .el-form-item--small.el-form-item {
  margin-bottom: 0px !important;
}

.formBox >>> .el-form-item__label {
  font-size: 12px !important;
  padding: 0 !important;
}
</style>
